package com.mes.basicdata.dao;

import org.springframework.stereotype.Repository;

import com.mes.basicdata.dao.iface.IFileObjectRelationDao;
import com.mes.basicdata.domain.FileObjectRelation;
import com.mes.basicdata.domain.FileObjectRelation;
import com.mes.common.dao.BasicDao;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


@Repository
public class FileObjectRelationDao extends BasicDao<FileObjectRelation> implements IFileObjectRelationDao {
	private static final Log log = LogFactory.getLog(FileObjectRelationDao.class);

	

//	public FileFieldDao() {
//		super(ObjectConstants.FILEFIELD_OBJECT_NAME);
//	}
//
//	@SuppressWarnings("unchecked")
//	public List<FileField> find(String fieldUid, String fileUid,
//			String fieldType) throws BaseDBException {
//		try {
//			String hql = "from " + getObjectName()
//					+ " where id.fileUid=? and id.fieldUid=? and fieldType=?";
//			List list = getHibernateTemplate().find(hql,
//					new Object[] { fileUid, fieldUid, fieldType });
//			return list;
//		} catch (HibernateException e) {
//			e.printStackTrace();
//			throw new BaseDBException(e.getMessage());
//		}
//
//	}
//
//	public Boolean addDocument(String fieldUid, List<String> fileObjectUids,
//			String fieldType) throws BaseDBException {
//		try {
//			for (String fileUid : fileObjectUids) {
//				FileField ff = new FileField();
//				ff.setFileUid(fileUid);
//				ff.setFieldUid(fieldUid);
//				ff.setFieldType(fieldType);
//				this.add(ff);
//			}
//			return true;
//		} catch (RuntimeException e) {
//			log.error("添加文件失败！");
//			e.printStackTrace();
//			throw new BaseDBException(e.getMessage());
//		}
//	}
//
//	public Boolean deleteDocument(String fieldUid, List<String> fileObjectUids,
//			String filefieldType) throws BaseDBException {
//		try {
//			for (String fileUid : fileObjectUids) {
//				String hql = "delete from " + this.getObjectName()
//						+ " where fileUid = '" + fileUid + "' and fieldUid = '"
//						+ fileUid + "' and fieldType = '" + filefieldType + "'";
//				this.getSession().createQuery(hql).executeUpdate();
//			}
//			return true;
//		} catch (RuntimeException e) {
//			log.error("删除文件失败！");
//			e.printStackTrace();
//			throw new BaseDBException(e.getMessage());
//		}
//	}
//
//	public List<FileObject> getDocument(String fieldUid, String filefieldType)
//			throws BaseDBException {
//		try {
//			String hql = "select ff.file from " + this.getObjectName() + " ff "
//					+ " where ff.fieldUid = '" + fieldUid
//					+ "' and ff.fieldType = '" + filefieldType + "'";
//			return this.getSession().createQuery(hql).list();
//		} catch (RuntimeException e) {
//			log.error("获得文件失败！");
//			e.printStackTrace();
//			throw new BaseDBException(e.getMessage());
//		}
//	}
}
